package com.example.demo.mapper;

import com.example.demo.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    @Select("select * from blog where delete_flag=0 order by create_time desc")
    //查询博客列表
    List<BlogInfo> selectAllBlog();

    //根据博客ID,查询博客信息
    @Select("select * from blog where delete_flag=0 and id = #{blogId}")
    BlogInfo selectById(Integer blogId);

    //根据博客ID,修改博客信息
    Integer updateBlog(BlogInfo blogInfo);

    //插入博客
    @Insert("insert into blog(title,content, user_id) values(#{title},#{content},#{userId})")
    Integer insertBlog(BlogInfo blogInfo);

}
